package com.greedy.interceptor;

import com.greedy.bean.dto.UserDTO;

/**
 * @Author: Yanxy
 * @Date: Created in:2022-12-25
 * Description: 用户线程
 */
public class UserHolder {

    private static final ThreadLocal<UserDTO> THREAD_LOCAL = new ThreadLocal<>();

    public static void saveUser(UserDTO userDTO) {
        THREAD_LOCAL.set(userDTO);
    }

    public static UserDTO getUser() {
        return THREAD_LOCAL.get();
    }

    public static void removeUser() {
        THREAD_LOCAL.remove();
    }

}
